home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / soundu / tnypl210.zip / TEST.C < prev    next >
C/C++ Source or Header  |  1994-05-22  |  2KB  |  74 lines

  1. /* test.c */
  2.  
  3. #include <stdio.h>
  4. #include <conio.h>
  5. #include <malloc.h>
  6. #include <io.h>
  7. #include <fcntl.h>
  8. #include <i86.h>
  9. #include "modplay.h"
  10.  
  11. #define MUSICVOLUME 192
  12.  
  13. void FadeInMusic(void)
  14. {
  15.     int Volume;
  16.     for (Volume = 0; Volume <= MUSICVOLUME; Volume++) {
  17.         MODSetMusicVolume(Volume);
  18.         delay(6);
  19.     }
  20. }
  21. void FadeOutMusic(void)
  22. {
  23.     int Volume;
  24.     for (Volume = MUSICVOLUME; Volume >= 0; Volume--) {
  25.         MODSetMusicVolume(Volume);
  26.         delay(8);
  27.     }
  28. }
  29.  
  30. void TestSample(void)
  31. {
  32.     Sample *Ding;
  33.     if ((Ding = MODLoadSample("DING.WAV")) != NULL) {
  34.         printf("Press any key to test the WAV file and ESC to exit.\n");
  35.         while (getch() != 27)
  36.             MODPlaySample(4,Ding);
  37.         MODFreeSample(Ding);
  38.     }
  39.     else {
  40.         printf("Error loading WAV file. Press any key to exit.\n");
  41.         getch();
  42.     }
  43. }
  44.  
  45. void main(void)
  46. {
  47.     Module *Song;
  48.     word Port;
  49.     byte IRQ,DRQ;
  50.  
  51.     if (MODDetectCard(&Port,&IRQ,&DRQ)) {
  52.         printf("Sound Blaster not found.\n");
  53.         return;
  54.     }
  55.     printf("Sound Blaster found at Addr:%03x IRQ:%d DMA:%d\n",Port,IRQ,DRQ);
  56.     if ((Song = MODLoadModule("TEST.MOD")) != NULL) {
  57.         if (MODPlayModule(Song,5,22222,Port,IRQ,DRQ))
  58.             printf("Error initializing the sound system.\n");
  59.         else {
  60.             printf("Playing music...\n");
  61.             FadeInMusic();
  62.             TestSample();
  63.             FadeOutMusic();
  64.             MODStopModule();
  65.         }
  66.         MODFreeModule(Song);
  67.     }
  68.     else {
  69.         printf("Error loading modulefile.\n");
  70.     }
  71.     return;
  72. }
  73.  
  74.